
<template>
  <el-dialog v-model="ifShow" title="奖惩" width="60rem" :before-close="handleCancel">
    <el-form ref="formRef" :model="formData" :rules="rules" label-width="auto" class="demo-ruleForm" status-icon>
      <el-form-item label="操作类型" prop="op">
        <el-select v-model="formData.op" placeholder="请选择">
          <!-- <el-option :value="103" label="奖励"></el-option> -->
          <el-option :value="202" label="罚款"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="平台" prop="platformId">
        <el-select clearable v-model="formData.platformId" placeholder="请选择">
          <el-option v-for="item in platFormArr" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="金额" prop="fund">
        <el-input placeholder="请输入" v-model="formData.fund"></el-input>
      </el-form-item>
      <el-form-item label="标题" prop="title">
        <el-select v-model="formData.title" v-if="formData.op == 202">
          <el-option value="付费改派">付费改派</el-option>
          <el-option value="一级违规-未按规定接引乘客(等待位置偏差)">一级违规-未按规定接引乘客(等待位置偏差)</el-option>
          <el-option value="一级违规-未按规定接引乘客(未提拿行李等)">一级违规-未按规定接引乘客(未提拿行李等)</el-option>
          <el-option value="一级违规-未按规则联系乘客">一级违规-未按规则联系乘客</el-option>
          <el-option value="一级违规-未与乘客确认路线,未开启导航">一级违规-未与乘客确认路线,未开启导航</el-option>
          <el-option value="一级违规-不按规范操作">一级违规-不按规范操作</el-option>
          <el-option value="一级违规-服务态度问题">一级违规-服务态度问题</el-option>
          <el-option value="一级违规-司机仪容仪表不合规,有异味等">一级违规-司机仪容仪表不合规,有异味等</el-option>
          <el-option value="一级违规-打扰乘客(轻微骚扰,播放音乐等)">一级违规-打扰乘客(轻微骚扰,播放音乐等)</el-option>
          <el-option value="一级违规-车内外不整洁,车内温度不适宜">一级违规-车内外不整洁,车内温度不适宜</el-option>
          <el-option value="一级违规-车辆备品不全,硬件损坏">一级违规-车辆备品不全,硬件损坏</el-option>

          <el-option value="二级违规-未提供服务">二级违规-未提供服务</el-option>
          <el-option value="二级违规-减少用车里程数/减少用车时间">二级违规-减少用车里程数/减少用车时间</el-option>
          <el-option value="二级违规-司机诱导乘客取消订单">二级违规-司机诱导乘客取消订单</el-option>
          <el-option value="二级违规-迟到(未造成到场无车)">二级违规-迟到(未造成到场无车)</el-option>
          <el-option value="二级违规-未送达目的地">二级违规-未送达目的地</el-option>
          <el-option value="二级违规-车辆信息推送不及时不准确(非人车不符)">二级违规-车辆信息推送不及时不准确(非人车不符)</el-option>
          <el-option value="二级违规-车辆配置不达标">二级违规-车辆配置不达标</el-option>
          <el-option value="二级违规-司机引导客户消费/推销购物">二级违规-司机引导客户消费/推销购物</el-option>

          <el-option value="三级违规-绕路">三级违规-绕路</el-option>
          <el-option value="三级违规-未按规定开票">三级违规-未按规定开票</el-option>
          <el-option value="三级违规-未按规定收取乘客费用">三级违规-未按规定收取乘客费用</el-option>
          <el-option value="三级违规-拖延服务时长">三级违规-拖延服务时长</el-option>
          <el-option value="三级违规-车上有人">三级违规-车上有人</el-option>
          <el-option value="三级违规-虚拟报备">三级违规-虚拟报备</el-option>
          <el-option value="三级违规-虚假交易">三级违规-虚假交易</el-option>
          <el-option value="三级违规-司机或供应商原因导致未用车">三级违规-司机或供应商原因导致未用车</el-option>
          <el-option value="三级违规-不安全驾驶(非违法交通法行为)">三级违规-不安全驾驶(非违法交通法行为)</el-option>

          <el-option value="四级违规-扰乱平台">四级违规-扰乱平台</el-option>
          <el-option value="四级违规-拒绝归还/损坏乘客财务">四级违规-拒绝归还/损坏乘客财务</el-option>
          <el-option value="四级违规-安全事故报备不及时">四级违规-安全事故报备不及时</el-option>
          <el-option value="四级违规-提供虚假证明材料">四级违规-提供虚假证明材料</el-option>
          <el-option value="四级违规-司机飞单">四级违规-司机飞单</el-option>
          <el-option value="四级违规-携毒/贩毒/吸毒 背调不合规">四级违规-携毒/贩毒/吸毒 背调不合规</el-option>
          <el-option value="四级违规-车辆无运营资质">四级违规-车辆无运营资质</el-option>
          <el-option value="四级违规-人车不符">四级违规-人车不符</el-option>
          <el-option value="四级违规-司机或车辆信息虚假">四级违规-司机或车辆信息虚假</el-option>
          <el-option value="四级违规-危险驾驶">四级违规-危险驾驶</el-option>
          <el-option value="四级违规-私下骚扰/恶意辱骂/欺骗乘客">四级违规-私下骚扰/恶意辱骂/欺骗乘客</el-option>
          <el-option value="四级违规-肢体冲突">四级违规-肢体冲突-</el-option>
          <el-option value="四级违规-泄露乘客信息">四级违规-泄露乘客信息</el-option>
          <el-option value="四级违规-其他违法违规行为">四级违规-其他违法违规行为</el-option>
        </el-select>
        <el-input v-else v-model="formData.title" placeholder="请输入标题"></el-input>
      </el-form-item>
      <el-form-item label="简介" prop="desc">
        <el-input placeholder="请输入" v-model="formData.desc"></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleOk">确认</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import CommonApi from "@/api/common";
import JntApi from "@/api/jnt";
import Supplier from "@/api/supplier";
import { channelArr, bizTypeArr, orderTypeArr, platFormArr, carTypeArr } from "@/enums/common";
import DriverApi from "@/api/driver";

const props = defineProps<{}>();
const emit = defineEmits(["success"]);
const formRef: any = ref(null);
const formData: any = reactive({
  id: "",
  op: undefined,
  platformId: "",
  fund: "",
  title: "",
  desc: "",
});
const rules = reactive({
  op: [{ required: true, message: "请选择!" }],
  fund: [{ required: true, message: "请输入!" }],
  title: [{ required: true, message: "请选择!" }],
  platformId: [{ required: true, message: "请选择!" }],
});
const ifShow = ref(false);
function edit(row: any) {
  ifShow.value = true;
  //赋值
  row.fund = "";
  row.id = row.driverId;

  Object.assign(formData, row);
}

/**
 * 确定按钮点击事件
 */
async function handleOk() {
  await formRef.value.validate((valid: any, fields: any) => {
    if (valid) {
      let model: any = formData;
      DriverApi.driverReward(model).then((res: any) => {
        if (res.code == 0) {
          ElMessage.success(res.message);
          formRef.value.resetFields();
          emit("success");
          handleCancel();
        }
      });
    } else {
      console.log("error submit!", fields);
    }
  });
}

/**
 * 取消按钮回调事件
 */
function handleCancel() {
  formRef.value.resetFields();
  ifShow.value = false;
}

defineExpose({
  edit,
});
onMounted(() => {});
</script>
<style lang="scss" scoped>
.flex_box {
  display: flex;
  margin-bottom: 14px;
  position: relative;
}
</style>
